﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;


namespace UtopianGame.graphics.menu
{
    class MenuScreen : BaseMenu
    {
        private String message;
        public MenuScreen(ContentManager cm, String newMessage)
        {
            init(cm, newMessage);
        }

        protected void init(ContentManager cm, String newMessage)
        {
            base.init(cm);
            GlobalDataHolder.makeActive(this);
            spriteName = "turnSummaryScreen";
            sprite = cm.Load<Texture2D>(spriteName);
            boundingBox.Width = 736;
            boundingBox.Height = 536;

            message = newMessage;

            //Find where to draw the "close" button so that it is centered on
            //the menuScreen.
            int centerAlignmentNumber = 0;
            centerAlignmentNumber = boundingBox.X + (boundingBox.Width / 2);
            centerAlignmentNumber -= ((int)(GlobalDataHolder.baseFont.MeasureString("Close").X) / 2);

            addToSubObjectList(new CloseMenuButton(contentManager), centerAlignmentNumber, 500, 500);

        }

        public override void draw(SpriteBatch sb)
        {
            base.draw(sb);
            //centerAlignmentNumber is used to dynamically center text on top of the menu
            int centerAlignmentNumber = 0;
            centerAlignmentNumber = boundingBox.X + (boundingBox.Width/2);
            centerAlignmentNumber -= ((int)(GlobalDataHolder.baseFont.MeasureString(message).X) / 2);
            sb.DrawString(GlobalDataHolder.baseFont, message, new Microsoft.Xna.Framework.Vector2(centerAlignmentNumber, boundingBox.Y+8), Color.Black);
        }

        public override void removed()
        {
            GlobalDataHolder.makeEverythingActive();
        }
    }
}
